#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "tlsf.h"

int main()
{
	char cmd[80];
	int arg;
	tlsf_t tlfs;
	int fd;

	void* p = malloc(32*1024*1024);
	printf("pool addr: %p\n", p);

	// int pool = 0x80000000;
	uint64_t pool = (uint64_t)p;

	printf("main start pool = %p size = %x\n", pool, 32*1024*1024);
	tlfs = tlsf_create_with_pool(pool, 32*1024*1024);   //32M

	for (;;) {
		scanf("%s", cmd);
		if (strcmp(cmd, "alloc") == 0) {
			printf("+++input size:\n");
			scanf("%d",&arg);
			tlsf_malloc(tlfs,arg);
			printf("+++tlsf_malloc done\n");
		} else if (strcmp(cmd, "free") == 0) {
			printf("input fd:\n");
			scanf("%d",&arg);
			tlsf_free(tlfs,arg);
		} else	{

		}
	}

	free(p);

	return 0;
}
